package toOffer;

import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

/**
 * <h3>leetcode</h3>
 *
 * @author BigFaceCat
 * @date 2024/1/21 17:01
 * @description <p>寻找文件副本</p>
 */
public class toOffer2_2_120 {
    public static void main(String[] args) {
        int[] nums = {3, 1, 2, 3};
        System.out.println(findRepeatDocument(nums));
    }

    /**
     * @param nums
     * @return
     */
    public static int findRepeatDocument(int[] nums) {
        Arrays.sort(nums);
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] == nums[i - 1]) {
                return nums[i];
            }
        }
        return -1;
    }
}
